<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>页面图片滚动</title>
</head>
<body>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<div class="max-wrap top-banner">
    <ul class="banner-bar">
        <li style="background:url(https://www.xinmi.gov.cn//u/cms/xinmi/202005/03153809wexw.jpg) no-repeat center"></li>
        <li style="background:url(https://www.xinmi.gov.cn//u/cms/xinmi/202005/03153809ng17.jpg) no-repeat center"></li>
        <li style="background:url(https://www.xinmi.gov.cn//u/cms/xinmi/202005/03153810poc2.jpg) no-repeat center"></li>
        <li style="background:url(https://www.xinmi.gov.cn//u/cms/xinmi/202005/03153811xqy3.jpg) no-repeat center"></li>
    </ul>
    <div class="hd">
        <a class="prev"></a>
        <a class="next"></a>
    </div>
    <div class="banner-keyword">
        <li><img src="https://www.xinmi.gov.cn//r/cms/xinmi/cn/images/kh001.png" aria-hidden="true" /></li>
        <li><img src="https://www.xinmi.gov.cn//r/cms/xinmi/cn/images/kh002.png" aria-hidden="true" /></li>
        <li><img src="https://www.xinmi.gov.cn//r/cms/xinmi/cn/images/kh003.png" aria-hidden="true" /></li>
    </div>

    <script type="text/javascript">
        $(function(){
            var listN = $(".top-banner li").length;
            $(".top-banner ul li").eq(0).css("display","block").fadeIn(1000);
            var sw = 1;
            function myShow(i){
                $(".top-banner ul li").eq(i).stop(true,true).fadeIn(1000).siblings("li").fadeOut(1000);
            }
            //滑入停止动画，滑出开始动画
            $(".top-banner").hover(function(){
                if(myTime){
                    clearInterval(myTime);
                }
            },function(){
                myTime = setInterval(function(){
                    myShow(sw)
                    sw++;
                    if(sw==listN){sw=0;}
                } , 5000);
            });
            //自动开始
            var myTime = setInterval(function(){
                myShow(sw)
                sw++;
                if(sw==listN){sw=0;}
            } , 5000);
            $(".top-banner .hd .prev").click(function(){
                if(sw<=0){sw = listN-1;}else{sw = sw-1;}
                myShow(sw);
            })
            $(".top-banner .hd .next").click(function(){
                if( sw == listN-1){sw=0;}else{sw = sw+1;}
                myShow(sw);
            })
        });

        (function(){
            var sliderF = function(ele, dur, delay, rightWidth) {
                ele = $(ele);
                var children = ele.find(">*").css({
                    opacity: 0,
                    right: rightWidth + 'px'
                });
                var firstChildren = children.eq(0);
                var slider = function() {
                    window.setTimeout(function() {
                        firstChildren.stop(true).animate({
                            right: 0,
                            opacity: 1
                        }, dur, 'linear', function() {
                            window.setTimeout(function() {
                                firstChildren.stop(true).animate({
                                    right: rightWidth + 'px',
                                    opacity: 0
                                }, dur, 'linear', function() {
                                    firstChildren = !firstChildren.next()[0] ? children.eq(0) : firstChildren.next();
                                    return slider();
                                });
                            }, delay)
                        });
                    }, 2000)
                }
                slider();
            }
            sliderF(".banner-keyword", 1000, 5000, 80);
        })();
    </script>
    <style type="text/css">
        /*top-banner start*/
        .top-banner{
            position:relative;
            height:295px;
            width:1200px;
            margin:0 auto;
            overflow:hidden;
        }
        .banner-bar li{
            height:295px;
            display:none;
            left:0;
            min-width:1000px;
            position:absolute;
            top:0;
            width:100%;
        }
        .banner-keyword{
            position:absolute;
            top:90px;
            right:0;
            width:530px;
            margin:0 auto;
            list-style-type: none;
        }
        .banner-keyword > li{
            position:absolute;
            opacity:0;
        }
        .top-banner .hd a{
            top:45% !important;
        }
        .top-banner .hd a{
            display:none !important;
        }
    </style>
</div>
</body>
</html>